﻿using CacheManager.Core;
using System;

namespace CacheManagerProj
{
    class Program
    {
        static void Main(string[] args)
        {
            var cache = CacheFactory.Build<string>(s => s.WithDictionaryHandle());
            //cache.OnAdd += (sender, args) => Console.WriteLine("Added " + args.Key);
            //cache.OnGet += (sender, args) => Console.WriteLine("Got " + args.Key);
            //cache.OnRemove += (sender, args) => Console.WriteLine("Removed " + args.Key);


            cache.OnAdd += Cache_OnAdd;
            cache.OnGet += Cache_OnGet;
            cache.OnRemove += Cache_OnRemove;

            cache.Add("key", "value");
            var val = cache.Get("key");
            cache.Remove("key");


            cache.AddOrUpdate("myKey", "someregion", "value", _ => "new value");
            cache.AddOrUpdate("myKey", "someregion", "value", _ => "new value");
            cache.Expire("myKey", "someregion", TimeSpan.FromMinutes(10));


            cache.Add("a", "b");


            //https://github.com/MichaCo/CacheManager/blob/dev/samples/CacheManager.Examples/Program.cs

        }

        private static void Cache_OnRemove(object sender, CacheManager.Core.Internal.CacheActionEventArgs e)
        {
            Console.WriteLine("Added " + e.Key);
        }

        private static void Cache_OnGet(object sender, CacheManager.Core.Internal.CacheActionEventArgs e)
        {
            Console.WriteLine("Got " + e.Key);
        }

        private static void Cache_OnAdd(object sender, CacheManager.Core.Internal.CacheActionEventArgs e)
        {
            Console.WriteLine("Removed " + e.Key);
        }
    }
}
